#ifndef __COMMON_H__
#define __COMMON_H__

#include "../inc/rps_access.h"

#define REDIS_RECONN_TIME 10
#define REDIS_CHECK_TIME 10
#define HEART_BEAT_INTERVAL 120
#define HEART_BEAT_TIMEDOUT 300
#define REDIS_EXPIRE_TIME 30
#define RPS_ACCESS_PORT 6660
#define REDIS_CENTER_IP "10.10.18.2"
#define REDIS_STATUS_PORT 6379
#define DEVICE_REGISTER "MSG_AGENT_REGISTER_REQ"
#define CLIENT_QUERY_STATUS "MSG_CLI_NEED_CON_REQ"

int device_register(conn* c, std::string uuid, std::string area, std::string oemid, std::string dev_port);

void insert_hash_table(std::string uuid, conn* c);

void delete_hash_table(std::string uuid);

conn* check_hash_table(std::string uuid);

void timer_handler(int fd, short which, void* args);

void update_timer(struct event* timer, int sec);

std::string get_string(const Json::Value& table);

void redis_conn_cb(const struct redisAsyncContext* ctx, int status);

void redis_check_health_cb(const int fd, short events, void* args);

void redis_op_status(redisAsyncContext* ctx, void* reply, void* args);

void redis_reconn_cb(const int fd, short events, void* args);

void redis_disconn_cb(const struct redisAsyncContext* ctx, int status);

#endif
